CREATE TABLE [dbo].[DnnProduct_CoreMessaging_MessageAttachments]
(
[MessageAttachmentID] [int] NOT NULL IDENTITY(1, 1),
[MessageID] [int] NOT NULL,
[FileID] [int] NULL,
[CreatedByUserID] [int] NULL,
[CreatedOnDate] [datetime] NULL,
[LastModifiedByUserID] [int] NULL,
[LastModifiedOnDate] [datetime] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DnnProduct_CoreMessaging_MessageAttachments] ADD CONSTRAINT [PK_DnnProduct_CoreMessaging_MessageAttachments] PRIMARY KEY CLUSTERED  ([MessageAttachmentID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_DnnProduct_CoreMessaging_MessageAttachments_MessageID] ON [dbo].[DnnProduct_CoreMessaging_MessageAttachments] ([MessageID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DnnProduct_CoreMessaging_MessageAttachments] ADD CONSTRAINT [FK_DnnProduct_CoreMessaging_MessageAttachments_DnnProduct_CoreMessaging_Messages] FOREIGN KEY ([MessageID]) REFERENCES [dbo].[DnnProduct_CoreMessaging_Messages] ([MessageID]) ON DELETE CASCADE
GO
